
var BankLoanShortRateArray6 =  [0.051,0.0434,0.0561,0.0535,0.0375,0.0589,0.056,0.0392,0.0476,0.0616,0.0585,0.041,0.0497,0.0644,0.061,0.0519,0.0671,0.0585,0.0468,0.0497,0.0644];
var BankLoanShortRateArray12 = [0.0556,0.0473,0.0612,0.0581,0.0407,0.0639,0.0606,0.0424,0.0515,0.0667,0.0631,0.0442,0.0536,0.0694,0.0656,0.0558,0.0722,0.0631,0.0505,0.0536,0.0694];
var BankLoanShortRateArray36 = [0.056,0.0476,0.0616,0.0585,0.041,0.0644,0.061,0.0427,0.0519,0.0671,0.064,0.0448,0.0544,0.0704,0.0665,0.0565,0.0732,0.064,0.0512,0.0544,0.0704];
var BankLoanShortRateArray60 = [0.0596,0.0507,0.0656,0.0622,0.0435,0.0684,0.0645,0.0452,0.0548,0.071,0.0665,0.0466,0.0565,0.0732,0.069,0.0586,0.0759,0.0665,0.0532,0.0565,0.0732];
var BankLoanLongRateArray =    [0.0614,0.0522,0.0675,0.064,0.0448,0.0704,0.066,0.0462,0.0561,0.0726,0.068,0.0476,0.0578,0.0748,0.0705,0.0599,0.0775,0.068,0.0544,0.0578,0.0748];
var FundLoanShortRateArray = [0.0350,0.0375,0.04,0.042,0.0445,0.042];
var FundLoanLongRateArray = [0.0405,0.043,0.045,0.047,0.049,0.047];

var loantype = 0; //0 代表 商业贷款；1 代表 公积金贷款；2 代表 组合型贷款
var loandeadline = 240; //240期  20 * 12
var bankloanspan = 4; //（0 代表 6月）（1 代表 1年）（2 代表 1~3年）（3 代表 3~5年）（4 代表 5~30年）
var fundloanspan = 1; //（0 代表 1~5年）（1 代表 5~30年）
var bankloanrate = 17; //默认为12年06月08日基准利率
var fundloanrate = 5; //默认为12年06月08日后
var paymethod = 0; //0 代表 等额本息；1 代表 等额本金

function LoanRateTextUpdate()
{
	var temp;
	if(loantype == 0)
	{
		if(bankloanrate == -1)
		{
			document.getElementById("BankLoanRateText").value = 0.00;
		}
		else
		{
			if(bankloanspan == 0)
			{
				temp = ((BankLoanShortRateArray6[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 1)
			{
				temp = ((BankLoanShortRateArray12[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 2)
			{
				temp = ((BankLoanShortRateArray36[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 3)
			{
				temp = ((BankLoanShortRateArray60[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 4)
			{
				temp = ((BankLoanLongRateArray[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
		}
	}
	
	if(loantype == 1)
	{
		if(fundloanrate == -1)
		{
			document.getElementById("FundLoanRateText").value = 0.00;
		}
		else
		{
			if(fundloanspan == 0)
			{
				temp = ((FundLoanShortRateArray[fundloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("FundLoanRateText").value = temp;
			}
			else
			{
				temp = ((FundLoanLongRateArray[fundloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("FundLoanRateText").value = temp;
			}
		}
	}
	
	if(loantype == 2)
	{
		if(bankloanrate == -1)
		{
			document.getElementById("BankLoanRateText").value = 0.00;
		}
		else
		{
			if(bankloanspan == 0)
			{
				temp = ((BankLoanShortRateArray6[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 1)
			{
				temp = ((BankLoanShortRateArray12[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 2)
			{
				temp = ((BankLoanShortRateArray36[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 3)
			{
				temp = ((BankLoanShortRateArray60[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
			else if(bankloanspan == 4)
			{
				temp = ((BankLoanLongRateArray[bankloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("BankLoanRateText").value = temp;
			}
		}
		
		if(fundloanrate == -1)
		{
			document.getElementById("FundLoanRateText").value = 0.00;
		}
		else
		{
			if(fundloanspan == 0)
			{
				temp = ((FundLoanShortRateArray[fundloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("FundLoanRateText").value = temp;
			}
			else
			{
				temp = ((FundLoanLongRateArray[fundloanrate]) * 10000)/100;
				temp = Math.round(temp*100)/100;
				document.getElementById("FundLoanRateText").value = temp;
			}			
		}
	}
}

function AutoHeight()
{
	baidu.app.autoHeight();
}

function LoanTypeSelect(Checked)
{
	if(Checked==0)
	{
	  document.getElementById("ID_BankLoanAmount").style.display = "inline";	
	  document.getElementById("ID_FundLoanAmount").style.display = "none";
	  document.getElementById("ID_BankLoanRate").style.display = "inline";
	  document.getElementById("ID_FundLoanRate").style.display = "none";
	  document.getElementById("ID_AllPayRate").style.display = "none";
	  document.getElementById("Background").style.height = "700px";
	  document.getElementById("HouseLoanCalculator").style.height = "600px";  
	  baidu.app.setHeight(700,AutoHeight);
	  loantype = 0;
	}
	
	if(Checked==1)
	{

	  document.getElementById("ID_BankLoanAmount").style.display = "none";
	  document.getElementById("ID_FundLoanAmount").style.display = "inline";
	  document.getElementById("ID_BankLoanRate").style.display = "none";
	  document.getElementById("ID_FundLoanRate").style.display = "inline";
	  document.getElementById("ID_AllPayRate").style.display = "none";
	  document.getElementById("Background").style.height = "700px";
	  document.getElementById("HouseLoanCalculator").style.height = "600px";
	  baidu.app.setHeight(700,AutoHeight);
	  loantype = 1;
	}

	if(Checked==2)
	{        
	   document.getElementById("ID_BankLoanAmount").style.display = "inline";
	   document.getElementById("ID_FundLoanAmount").style.display = "inline";
	   document.getElementById("ID_BankLoanRate").style.display = "inline";
	   document.getElementById("ID_FundLoanRate").style.display = "inline";
	   document.getElementById("ID_AllPayRate").style.display = "inline";
	   document.getElementById("Background").style.height = "790px";
	   document.getElementById("HouseLoanCalculator").style.height = "693px";
	   baidu.app.setHeight(790,AutoHeight);
	   loantype = 2;
	}
	
	LoanRateTextUpdate();
}

function LoanDeadlineSelect(select)
{
	if(select.selectedIndex == 0)
	{
		loandeadline = 6;
		bankloanspan = 0;
		fundloanspan = 0;
	}
	else if(select.selectedIndex == 1)
	{
		loandeadline = (select.selectedIndex * 12);
		bankloanspan = 1;
		fundloanspan = 0;
	}
	else if(select.selectedIndex <= 3)
	{
		loandeadline = (select.selectedIndex * 12);
		bankloanspan = 2;
		fundloanspan = 0;
	}
	else if(select.selectedIndex <= 5)
	{
		loandeadline = (select.selectedIndex * 12);
		bankloanspan = 3;
		fundloanspan = 0;
	}
	else
	{
		loandeadline = (select.selectedIndex * 12);
		bankloanspan = 4;
		fundloanspan = 1;
	}
	
	LoanRateTextUpdate();
}

function BankLoanRateSelect(select)
{
	bankloanrate = (select.selectedIndex - 1);
	
	var temp;
	
	if(bankloanrate == -1)
	{
		document.getElementById("BankLoanRateText").value = 0.00;
	}
	else
	{
		if(bankloanspan == 0)
		{
			temp = ((BankLoanShortRateArray6[bankloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("BankLoanRateText").value = temp;
		}
		else if(bankloanspan == 1)
		{
			temp = ((BankLoanShortRateArray12[bankloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("BankLoanRateText").value = temp;
		}
		else if(bankloanspan == 2)
		{
			temp = ((BankLoanShortRateArray36[bankloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("BankLoanRateText").value = temp;
		}
		else if(bankloanspan == 3)
		{
			temp = ((BankLoanShortRateArray60[bankloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("BankLoanRateText").value = temp;
		}
		else if(bankloanspan == 4)
		{
			temp = ((BankLoanLongRateArray[bankloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("BankLoanRateText").value = temp;
		}	
	}
}

function FundLoanRateSelect(select)
{
	fundloanrate = (select.selectedIndex - 1);
	
	var temp;
	
	if(fundloanrate == -1)
	{
		document.getElementById("FundLoanRateText").value = 0.00;
	}
	else
	{
		if(fundloanspan == 0)
		{
			temp = ((FundLoanShortRateArray[fundloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("FundLoanRateText").value = temp;
		}
		else
		{
			temp = ((FundLoanLongRateArray[fundloanrate]) * 10000)/100;
			temp = Math.round(temp*100)/100;
			document.getElementById("FundLoanRateText").value = temp;
		}
	}
}

function PayMethodSelect(Checked)
{
	if(Checked==0)
	{
		paymethod = 0;
	}
	if(Checked==1)
	{
		paymethod = 1;
	}
}

function BankLoanAmountInputExamine()
{
	if(document.getElementById("BankLoanAmount").value == "")
	{
	  document.getElementById("ID_BankLoanLable").innerHTML = "不能空";
	  document.getElementById("ID_BankLoanLable").style.color = "#ff0000";
	  return 0;
	}
	else
	{
	  document.getElementById("ID_BankLoanLable").innerHTML = "";
	  return 1;
	}
}
function FundLoanAmountInputExamine()
{
	if(document.getElementById("FundLoanAmount").value == "")
	{
	  document.getElementById("ID_FundLoanLable").innerHTML = "不能空";
	  document.getElementById("ID_FundLoanLable").style.color = "#ff0000";
	  return 0;
	}
	else
	{
	  document.getElementById("ID_FundLoanLable").innerHTML = "";
	  return 1;
	}
}
function BankLoanRateInputExamine()
{
	if(document.getElementById("BankLoanRateText").value == "")
	{
	  document.getElementById("ID_BankLoanRateLable").innerHTML = "不能空";
	  document.getElementById("ID_BankLoanRateLable").style.color = "#ff0000";
	  return 0;
	}
	else
	{
	  document.getElementById("ID_BankLoanRateLable").innerHTML = "";
	  return 1;
	}
}
function FundLoanRateInputExamine()
{
	if(document.getElementById("FundLoanRateText").value == "")
	{
	  document.getElementById("ID_FundLoanRateLable").innerHTML = "不能空";
	  document.getElementById("ID_FundLoanRateLable").style.color = "#ff0000";
	  return 0;
	}
	else
	{
	  document.getElementById("ID_FundLoanRateLable").innerHTML = "";
	  return 1;
	}
}

//等额本息 计算方式
function CalculateOne()
{
	var Deadline = loandeadline;
	var datalist = "";
	var i;
	var a; //偿还本息
	var b; //偿还利息
	var c; //偿还本金
	var d; //剩余本金
	
	var divtable = document.getElementById("DataList");
	
	if(loantype == 0)
	{
		var Amount = parseFloat(document.getElementById("BankLoanAmount").value) * 10000;
		var Rate = parseFloat(document.getElementById("BankLoanRateText").value)/1200;
	
		var TotalRate = (Amount*Deadline*Rate*Math.pow((1+Rate),Deadline))/(Math.pow((1+Rate),Deadline)-1) - Amount;
		TotalRate = Math.round(TotalRate*100)/100;
		var TotalRepay = TotalRate + Amount;
		TotalRepay = Math.round(TotalRepay*100)/100;
		
		document.getElementById("TotalRateAmount").value = TotalRate;
		document.getElementById("TotalRepayAmount").value = TotalRepay;
		
		a = TotalRepay / Deadline;
		a = Math.round(a*100)/100;
		
		datalist += "<table class=\"datalisttable\" frame=\"void\" rules=\"rows\">";
		
		for(i=1;i<=Deadline;i++)
		{
			b = (Amount*Rate*(Math.pow((1+Rate),Deadline) - Math.pow((1+Rate),(i-1)))) / (Math.pow((1+Rate),Deadline)-1);
			b = Math.round(b*100)/100;
			c = a - b;
			c = Math.round(c*100)/100;
			d = (Amount*(Math.pow((1+Rate),Deadline) - Math.pow((1+Rate),i))) / (Math.pow((1+Rate),Deadline)-1);
			d = Math.round(d*100)/100;
			datalist += "<tr align=\"center\">";
			datalist = datalist + "<td width=\"10%\">" + i + "</td>"; //期数
			datalist = datalist + "<td width=\"22.5%\">" + a + "</td>"; //偿还本息
			datalist = datalist + "<td width=\"22.5%\">" + b + "</td>"; //偿还利息
			datalist = datalist + "<td width=\"22.5%\">" + c + "</td>"; //偿还本金
			datalist = datalist + "<td width=\"22.5%\">" + d + "</td>"; //剩余本金
			datalist += "</tr>";
		}
		datalist += "</table>";
		divtable.innerHTML = datalist;
	}
	
	if(loantype == 1)
	{
		var Amount2 = parseFloat(document.getElementById("FundLoanAmount").value) * 10000;
		var Rate2 = parseFloat(document.getElementById("FundLoanRateText").value)/1200;
	
		var TotalRate2 = (Amount2*Deadline*Rate2*Math.pow((1+Rate2),Deadline))/(Math.pow((1+Rate2),Deadline)-1) - Amount2;
		TotalRate2 = Math.round(TotalRate2*100)/100;
		var TotalRepay2 = TotalRate2 + Amount2;
		TotalRepay2 = Math.round(TotalRepay2*100)/100;
		
		document.getElementById("TotalRateAmount").value = TotalRate2;
		document.getElementById("TotalRepayAmount").value = TotalRepay2;
		
		a = TotalRepay2 / Deadline;
		a = Math.round(a*100)/100;

		datalist += "<table class=\"datalisttable\" frame=\"void\" rules=\"rows\">";
		
		for(i=1;i<=Deadline;i++)
		{
			b = (Amount2*Rate2*(Math.pow((1+Rate2),Deadline) - Math.pow((1+Rate2),(i-1)))) / (Math.pow((1+Rate2),Deadline)-1);
			b = Math.round(b*100)/100;
			c = a - b;
			c = Math.round(c*100)/100;
			d = (Amount2*(Math.pow((1+Rate2),Deadline) - Math.pow((1+Rate2),i))) / (Math.pow((1+Rate2),Deadline)-1);
			d = Math.round(d*100)/100;
			datalist += "<tr align=\"center\">";
			datalist = datalist + "<td width=\"10%\">" + i + "</td>"; //期数
			datalist = datalist + "<td width=\"22.5%\">" + a + "</td>"; //偿还本息
			datalist = datalist + "<td width=\"22.5%\">" + b + "</td>"; //偿还利息
			datalist = datalist + "<td width=\"22.5%\">" + c + "</td>"; //偿还本金
			datalist = datalist + "<td width=\"22.5%\">" + d + "</td>"; //剩余本金
			datalist += "</tr>";
		}
		datalist += "</table>";
		divtable.innerHTML = datalist;
	}
	
	if(loantype == 2)
	{
		var BankAmount = parseFloat(document.getElementById("BankLoanAmount").value) * 10000;
		var BankRate = parseFloat(document.getElementById("BankLoanRateText").value)/1200;
	
		var BankTotalRate = (BankAmount*Deadline*BankRate*Math.pow((1+BankRate),Deadline))/(Math.pow((1+BankRate),Deadline)-1) - BankAmount;
		BankTotalRate = Math.round(BankTotalRate*100)/100;
		var BankTotalRepay = BankTotalRate + BankAmount;
		
		var FundAmount = parseFloat(document.getElementById("FundLoanAmount").value) * 10000;
		var FundRate = parseFloat(document.getElementById("FundLoanRateText").value)/1200;
	
		var FundTotalRate = (FundAmount*Deadline*FundRate*Math.pow((1+FundRate),Deadline))/(Math.pow((1+FundRate),Deadline)-1) - FundAmount;
		FundTotalRate = Math.round(FundTotalRate*100)/100;
		var FundTotalRepay = FundTotalRate + FundAmount;
		
		var Total_Rate = BankTotalRate + FundTotalRate;
		Total_Rate = Math.round(Total_Rate*100)/100;
		
		var Total_Repay = BankTotalRepay + FundTotalRepay;
		Total_Repay = Math.round(Total_Repay*100)/100;
		
		document.getElementById("BankLoanRateAmount").value = BankTotalRate;
		document.getElementById("FundLoanRateAmount").value = FundTotalRate;
		document.getElementById("TotalRateAmount").value = Total_Rate;
		document.getElementById("TotalRepayAmount").value = Total_Repay;
		
		a = Total_Repay / Deadline;
		a = Math.round(a*100)/100;
		
		datalist += "<table class=\"datalisttable\" frame=\"void\" rules=\"rows\">";
		
		for(i=1;i<=Deadline;i++)
		{
			b = (BankAmount*BankRate*(Math.pow((1+BankRate),Deadline) - Math.pow((1+BankRate),(i-1)))) / (Math.pow((1+BankRate),Deadline)-1);
			b += (FundAmount*FundRate*(Math.pow((1+FundRate),Deadline) - Math.pow((1+FundRate),(i-1)))) / (Math.pow((1+FundRate),Deadline)-1);
			b = Math.round(b*100)/100;
			c = a - b;
			c = Math.round(c*100)/100;
			d = (BankAmount*(Math.pow((1+BankRate),Deadline) - Math.pow((1+BankRate),i))) / (Math.pow((1+BankRate),Deadline)-1);
			d += (FundAmount*(Math.pow((1+FundRate),Deadline) - Math.pow((1+FundRate),i))) / (Math.pow((1+FundRate),Deadline)-1);
			d = Math.round(d*100)/100;
			datalist += "<tr align=\"center\">";
			datalist = datalist + "<td width=\"10%\">" + i + "</td>"; //期数
			datalist = datalist + "<td width=\"22.5%\">" + a + "</td>"; //偿还本息
			datalist = datalist + "<td width=\"22.5%\">" + b + "</td>"; //偿还利息
			datalist = datalist + "<td width=\"22.5%\">" + c + "</td>"; //偿还本金
			datalist = datalist + "<td width=\"22.5%\">" + d + "</td>"; //剩余本金
			datalist += "</tr>";
		}
		datalist += "</table>";
		divtable.innerHTML = datalist;
	}
	
}

//等额本金 计算方式
function CalculateTwo()
{
	var Deadline = loandeadline;
	var datalist = "";
	var i;
	var a; //偿还本息
	var b; //偿还利息
	var c; //偿还本金
	var d; //剩余本金
	
	var divtable = document.getElementById("DataList");
	
	if(loantype == 0)
	{
		var Amount = parseFloat(document.getElementById("BankLoanAmount").value) * 10000;
		var Rate = parseFloat(document.getElementById("BankLoanRateText").value)/1200;
	
		var TotalRate = (Amount*Rate*(Deadline+1))/2;
		TotalRate = Math.round(TotalRate*100)/100;
		var TotalRepay = TotalRate + Amount;
		TotalRepay = Math.round(TotalRepay*100)/100;
		
		document.getElementById("TotalRateAmount").value = TotalRate;
		document.getElementById("TotalRepayAmount").value = TotalRepay;
		
		c = Amount / Deadline;
		c = Math.round(c*100)/100;
		
		datalist += "<table class=\"datalisttable\" frame=\"void\" rules=\"rows\">";
		
		for(i=1;i<=Deadline;i++)
		{
			b = (Amount*Rate*(Deadline-i+1)) / Deadline;
			b = Math.round(b*100)/100;
			a = b + c;
			a = Math.round(a*100)/100;
			d = (Amount*(Deadline-i)) / Deadline;
			d = Math.round(d*100)/100;
			datalist += "<tr align=\"center\">";
			datalist = datalist + "<td width=\"10%\">" + i + "</td>"; //期数
			datalist = datalist + "<td width=\"22.5%\">" + a + "</td>"; //偿还本息
			datalist = datalist + "<td width=\"22.5%\">" + b + "</td>"; //偿还利息
			datalist = datalist + "<td width=\"22.5%\">" + c + "</td>"; //偿还本金
			datalist = datalist + "<td width=\"22.5%\">" + d + "</td>"; //剩余本金
			datalist += "</tr>";
		}
		datalist += "</table>";
		divtable.innerHTML = datalist;
	}
	
	if(loantype == 1)
	{
		var Amount2 = parseFloat(document.getElementById("FundLoanAmount").value) * 10000;
		var Rate2 = parseFloat(document.getElementById("FundLoanRateText").value)/1200;
	
		var TotalRate2 = (Amount2*Rate2*(Deadline+1))/2;
		TotalRate2 = Math.round(TotalRate2*100)/100;
		var TotalRepay2 = TotalRate2 + Amount2;
		TotalRepay2 = Math.round(TotalRepay2*100)/100;
		
		document.getElementById("TotalRateAmount").value = TotalRate2;
		document.getElementById("TotalRepayAmount").value = TotalRepay2;
		
		c = Amount2 / Deadline;
		c = Math.round(c*100)/100;
		
		datalist += "<table class=\"datalisttable\" frame=\"void\" rules=\"rows\">";
		
		for(i=1;i<=Deadline;i++)
		{
			b = (Amount2*Rate2*(Deadline-i+1)) / Deadline;
			b = Math.round(b*100)/100;
			a = b + c;
			a = Math.round(a*100)/100;
			d = (Amount2*(Deadline-i)) / Deadline;
			d = Math.round(d*100)/100;
			datalist += "<tr align=\"center\">";
			datalist = datalist + "<td width=\"10%\">" + i + "</td>"; //期数
			datalist = datalist + "<td width=\"22.5%\">" + a + "</td>"; //偿还本息
			datalist = datalist + "<td width=\"22.5%\">" + b + "</td>"; //偿还利息
			datalist = datalist + "<td width=\"22.5%\">" + c + "</td>"; //偿还本金
			datalist = datalist + "<td width=\"22.5%\">" + d + "</td>"; //剩余本金
			datalist += "</tr>";
		}
		datalist += "</table>";
		divtable.innerHTML = datalist;
	}
	
	if(loantype == 2)
	{
		var BankAmount = parseFloat(document.getElementById("BankLoanAmount").value) * 10000;
		var BankRate = parseFloat(document.getElementById("BankLoanRateText").value)/1200;
	
		var BankTotalRate = (BankAmount*BankRate*(Deadline+1))/2;
		BankTotalRate = Math.round(BankTotalRate*100)/100;
		var BankTotalRepay = BankTotalRate + BankAmount;
		
		var FundAmount = parseFloat(document.getElementById("FundLoanAmount").value) * 10000;
		var FundRate = parseFloat(document.getElementById("FundLoanRateText").value)/1200;
	
		var FundTotalRate = (FundAmount*FundRate*(Deadline+1))/2;
		FundTotalRate = Math.round(FundTotalRate*100)/100;
		var FundTotalRepay = FundTotalRate + FundAmount;
		
		var Total_Rate = BankTotalRate + FundTotalRate;
		Total_Rate = Math.round(Total_Rate*100)/100;
	
		var Total_Repay = BankTotalRepay + FundTotalRepay;
		Total_Repay = Math.round(Total_Repay*100)/100;
	
		document.getElementById("BankLoanRateAmount").value = BankTotalRate;
		document.getElementById("FundLoanRateAmount").value = FundTotalRate;
		document.getElementById("TotalRateAmount").value = Total_Rate;
		domains=document.getElementById("TotalRepayAmount").value = Total_Repay;
		 
		c = (BankAmount + FundAmount) / Deadline;
		c = Math.round(c*100)/100;
		
		datalist += "<table class=\"datalisttable\" frame=\"void\" rules=\"rows\">";

		for(i=1;i<=Deadline;i++)
		{
			b = (BankAmount*BankRate*(Deadline-i+1)) / Deadline;
			b += (FundAmount*FundRate*(Deadline-i+1)) / Deadline;
			b = Math.round(b*100)/100;
			a = b + c;
			a = Math.round(a*100)/100;
			d = (BankAmount*(Deadline-i)) / Deadline;
			d += (FundAmount*(Deadline-i)) / Deadline;
			d = Math.round(d*100)/100;
			datalist += "<tr align=\"center\">";
			datalist = datalist + "<td width=\"10%\">" + i + "</td>"; //期数
			datalist = datalist + "<td width=\"22.5%\">" + a + "</td>"; //偿还本息
			datalist = datalist + "<td width=\"22.5%\">" + b + "</td>"; //偿还利息
			datalist = datalist + "<td width=\"22.5%\">" + c + "</td>"; //偿还本金
			datalist = datalist + "<td width=\"22.5%\">" + d + "</td>"; //剩余本金
			datalist += "</tr>";
		}
		datalist += "</table>";
		divtable.innerHTML = datalist;
	}
	
}

function Calculate()
{
	if(loantype == 0)
	{
		var AmountExamine_1 = BankLoanAmountInputExamine();
		var RateExamine_1 = BankLoanRateInputExamine();
		
		if((AmountExamine_1 == 0) || (RateExamine_1 == 0))
		{
			return 0;
		}
		else
		{
			if(paymethod == 0)
			{
				CalculateOne();
			}
			else
			{
				CalculateTwo();
			}
		}
	}
	
	if(loantype == 1)
	{
		var AmountExamine_2 = FundLoanAmountInputExamine();
		var RateExamine_2 = FundLoanRateInputExamine();
		
		if((AmountExamine_2 == 0) || (RateExamine_2 == 0))
		{
			return 0;
		}
		else
		{
			if(paymethod == 0)
			{
				CalculateOne();
			}
			else
			{
				CalculateTwo();
			}
		}
	}
	
	if(loantype == 2)
	{
		var AmountExamine_11 = BankLoanAmountInputExamine();
		var RateExamine_11 = BankLoanRateInputExamine();
		var AmountExamine_22 = FundLoanAmountInputExamine();
		var RateExamine_22 = FundLoanRateInputExamine();
		
		if((AmountExamine_11 == 0) || (RateExamine_11 == 0) || (AmountExamine_22 == 0) || (RateExamine_22 == 0))
		{
			return 0;
		}
		else
		{
			if(paymethod == 0)
			{
				CalculateOne();
			}
			else
			{
				CalculateTwo();
			}
		}
	}
}

